package me.numark.activities;

import android.os.Bundle;
import android.support.v4.app.FragmentTransaction;
import android.widget.FrameLayout;

import butterknife.Bind;
import me.numark.R;
import me.numark.fragments.FriendsFragment;
import me.numark.fragments.ProfileFragment;
import me.numark.utils.Global;

public class FansActivity extends BaseActivity {

    @Bind(R.id.fragment)
    FrameLayout fragment;


    private FriendsFragment mFragment;

    private int userId;

    boolean isFromSetting = false;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        activity_layout_res = R.layout.activity_fans;
        super.onCreate(savedInstanceState);
        initUI();
        initParams();
        initFragment();
    }

    private void initParams() {
        userId = getIntent().getIntExtra(ProfileFragment.USER_ID, -1);
    }

    private void initUI() {
        titleTextView.setText("粉丝");
    }

    private void initFragment() {
        FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
        mFragment = FriendsFragment.newInstance(userId, isFromSetting, FriendsFragment.TYPE_FAN);
        ft.add(R.id.fragment, mFragment);
        ft.show(mFragment);
        ft.commitAllowingStateLoss();
    }

    @Override
    public void onBackPressed() {
        if (Global.isLoggedIn()) {
            super.onBackPressed();
        }
    }
}
